<?php
/**
 * RedCross Application
 *
 * @copyright Copyright (c) 2010, Kristian Stokke Tryggestad, Rune Vikestad, Andreas Flaten Wist, Simen Nicolai Echholt, Ole Henrik Jahren
 */


class Admin_Form_Member_Phone extends RedCross_Form
{
	public function init()
	{
		$this->addElement('text', 'phone', array(
			'filters'		=> array('StringTrim'),
			'validators'	=> array(
                array('Digits'),
				array('StringLength', true, array(8, 8)),
            ),
            'required' 	=> true,
            'label' 	=> 'Telefon'
		));

		$this->addElement('select', 'phonetype', array(
            'required' 	=> true,
            'label' 	=> 'Telefontype'
		));

        $phonetypeService = RedCross_Factory::getService('Core_Service_Phonetype');
		$phonetypes = $phonetypeService->fetchAll();
		foreach($phonetypes as $p) {
			$this->getElement('phonetype')->addMultiOption($p->id, $p->name);
		}

		$this->addElement('submit', Admin_MemberController::SUBMIT_PHONE, array(
            'required' => true,
            'ignore'   => true,
            'label'    => 'Legg til telefonnummer',
        ));

        $this->getElement(Admin_MemberController::SUBMIT_PHONE)->setDecorators($this->_buttonElementDecorators);
	}
}